package org.suyafei.manager.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.suyafei.manager.TrafficTaskManager;
import org.suyafei.mapper.TrafficTaskMapper;
import org.suyafei.model.TrafficTaskDO;

/**
 * @author 宿某人
 * @Date: 2022/03/24/10:45
 * @Description:
 */
@Component
@Slf4j
public class TrafficTaskManagerImpl implements TrafficTaskManager {


    @Autowired
    private TrafficTaskMapper trafficTaskMapper;

    /**
     * 新增
     *
     * @param trafficTaskDO
     * @return
     */
    @Override
    public int add(TrafficTaskDO trafficTaskDO) {
        return trafficTaskMapper.insert(trafficTaskDO);
    }

    /**
     * 根据用户Id和Id查询
     *
     * @param id
     * @param accountNo
     * @return
     */
    @Override
    public TrafficTaskDO findByIdAndAccountNo(Long id, Long accountNo) {
        return trafficTaskMapper.selectOne(new QueryWrapper<TrafficTaskDO>().eq("id", id).eq("account_no", accountNo));
    }

    /**
     * 根据用户Id和Id删除
     *
     * @param id
     * @param accountNo
     * @return
     */
    @Override
    public int deleteByIdAndAccountNo(Long id, Long accountNo) {
        return trafficTaskMapper.delete(new UpdateWrapper<TrafficTaskDO>().eq("id", id).eq("account_no", accountNo));
    }
}
